// pages/shop_in/shop_in.js
const date = new Date();
const years = [];
const months = [];
const days = [];
import { userPostsJian } from '../../api/api.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    parameter: {
      'navbar': '1',
      'return': '1',
      'title': '填写简历'
    }, IMG_URL: 'http://try11.jiaodaoren.com/zhusiyao/zhenyangyou/',
    MXH_IMG_URL: 'http://try11.jiaodaoren.com/zhusiyao/meixihujiancaicheng/',

    imageList: [], //评价图片列表
    /**后端所需参数 */
    business_all: [],
    agree_entry_rules: true,  //默认同意协议,
    sexList: [{
      name: '1',
      value: '男',
      checked: true
    },
    {
      name: '2',
      value: '女',
      checked: false
    }
    ], //性别

  /**求职list的值 */
    qiuzhiList: [{
      name: '1',
      value: '职场人',
      checked: true
    },
    {
      name: '2',
      value: '学生',
      checked: false
    }
    ], 



    zzList: [{
      name: '1',
      value: '在线教育',
      checked: false
    },
    {
      name: '2',
      value: '工程施工',
      checked: false
    },
    {
      name: '3',
      value: '移动互联网',
      checked: false
    }
    ],

    rzList: [{
      name: '1',
      value: 'D轮及以上',
      checked: false
    },
    {
      name: '2',
      value: 'C轮',
      checked: false
    },
    {
      name: '3',
      value: 'B轮',
      checked: false
    },
    {
      name: '4',
      value: 'A轮',
      checked: false
    }
    ],


    rsList: [{
      name: '1',
      value: '1-20',
      checked: false
    },
    {
      name: '2',
      value: '20-99',
      checked: false
    },
    {
      name: '2',
      value: '100-1000',
      checked: false
    },
    {
      name: '3',
      value: '1000-10000',
      checked: false
    },
    {
      name: '4',
      value: '1000-10000',
      checked: false
    }
    ],

    hx_Array_brand: [0],//默认显示一个,行业的数组长度
    hx_Input_text_brand: [],  /*当前行业的值 */
    showZZModal: false,
    zzText: '',
    rzText: '',
    rsText: '',
    showRZModal: false,
    showRSModal: false,
    qiuzhi_gender:1,
    qiuzhi_name:1,
    region: ['省', '市', '区'],
    /**出生年月 */
    years: years,
    year: date.getFullYear(),
    months: months,
    month: 2,
    days: days,
    day: 2,
    value: [9999, 1, 1],

    /**地址的选择 */
    valueRegion:[0,0,0],
    multiArray:[
      {
        0:[
          {
            0:'北京市',
            1: '天津市',
            2: '河北省',
          }
        ],
        1: [
          {
            0: '北京市',
            1: '天津市',
            2: '河北省',
          }
        ],
        2: [
          {
            0: '北京市',
            1: '天津市',
            2: '河北省',
          }
        ]
      }
    ],
    region: ['山西省', '阳泉市','市辖区']
    /**地址的选择结束 */
  },

  /**提交 */
  applySubmit:function(e){
    var data = e.detail.value, that = this;
    // data['zhuyin_name'] = this.data.zzText;
    // data['financing_name'] = this.data.rzText;
    // data['person_name'] = this.data.rsText;
    // data['mch_license'] = this.data.mch_license;
    userPostsJian(data).then(res => {
      console.log('res的值', res);
      if (res.status == 200) {
        console.log('执行了1');
        me.urlToast('提交简历成功!', '/pages/index/index', 1000, 0, 1);
      } else {
        console.log('执行了2');
        me.urlToast('提交简历失败,请重试!', '/pages/index/index', 1000, 0, 1);
      }
    }).catch(err => {
      that.setData({ loading: false, loadTitle: "加载更多" });
    })
  },
  //改变性别
  handleChangeSexList(e) {
    let that = this;
    this.data.sexList.forEach((item, index) => {
      if (item.name == e.detail.value) {
         this.data.qiuzhi_gender = item.name;
        item.checked = true
      } else {
        item.checked = false
      }
    })
    this.setData({
      sexList: this.data.sexList
    })
  },
  get_chusheng(){
    console.log('执行了出生');
    for (let i = 1990; i <= date.getFullYear(); i++) {
      years.push(i)
    }
    for (let i = 1; i <= 12; i++) {
      months.push(i)
    }
    for (let i = 1; i <= 31; i++) {
      days.push(i)
    }
    this.setData({
      years,
      months,
      days
    })
  },
  bindChange_chusheng: function (e) {
    const val = e.detail.value
    this.setData({
      year: this.data.years[val[0]],
      month: this.data.months[val[1]],
      day: this.data.days[val[2]]
    })
  },


  //改变求职身份
  handleChangeQiuzhiList(e) {
    let that = this;
    this.data.qiuzhiList.forEach((item, index) => {
      if (item.name == e.detail.value) {
        this.data.qiuzhi_name = item.name;
        item.checked = true
      } else {
        item.checked = false
      }
    })
    this.setData({
      qiuzhiList: this.data.qiuzhiList
    })
  },


  //打开政治面貌选择弹窗
  showZZPopup() {
    this.setData({
      showZZModal: true
    });
  },
  //改变政治面貌
  handleChangeZZ(e) {
    let text = e.detail.value, Attr = this.data.zzList, that = this;
    Attr.forEach(item => {
      if (item.value == text) {
        that.setData({
          'zzTextId': item.name
        })
      }
    });
    this.setData({
      zzText: e.detail.value,
      showZZModal: false
    })
  },
  //关闭政治面貌选择弹窗
  onCloseZZModal() {
    this.setData({
      showZZModal: false
    });
  },


  //打开融资选择弹窗
  showRZPopup() {
    this.setData({
      showRZModal: true
    });
  },
  //改变政治面貌
  handleChangeRZ(e) {
    let text = e.detail.value, Attr = this.data.rzList, that = this;
    Attr.forEach(item => {
      if (item.value == text) {
        that.setData({
          'rzTextId': item.name
        })
      }
    });
    this.setData({
      rzText: e.detail.value,
      showRZModal: false
    })
  },
  //关闭政治面貌选择弹窗
  onCloseRZModal() {
    this.setData({
      showRZModal: false
    });
  },





  //打开融资选择弹窗
  showRSPopup() {
    this.setData({
      showRSModal: true
    });
  },
  //改变政治面貌
  handleChangeRS(e) {
    let text = e.detail.value, Attr = this.data.rsList, that = this;
    Attr.forEach(item => {
      if (item.value == text) {
        that.setData({
          'rsTextId': item.name
        })
      }
    });
    this.setData({
      rsText: e.detail.value,
      showRSModal: false
    })
  },
  //关闭政治面貌选择弹窗
  onCloseRSModal() {
    this.setData({
      showRSModal: false
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    /**加载出生年月 */
    this.get_chusheng();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})